<?php
namespace Ntxx\Controller;
use Think\Controller;
class RankController extends Controller {

	public function personal(){
		$date = date("Y-m-d");
		$data = M("testee")->join('g_ntxx_group on g_ntxx_group.id=g_ntxx_testee.group')
            ->where("score1 is not null and score1>=60")
			->field("tname,name as gname,GREATEST(IFNULL(score1, 0),IFNULL(score2,0)) as score,right(pphone,4) as ssn")
            ->order("score desc,finishtime asc")->select();
//        dump($data);
		$this->assign("data",$data);
		$this->display();
	}


    public function company(){
        $data = M("group")->join('g_ntxx_testee ON g_ntxx_group.id = g_ntxx_testee.group', 'LEFT')
            ->field("name,pc,iF((count(g_ntxx_testee.group)/`pc`*100)>100, 100.00,                  
                          cast(count(g_ntxx_testee.group)/`pc`*100 as decimal(5,2)) ) as ps ")
            ->group("g_ntxx_group.id")
            ->where("g_ntxx_group.id not in (10142,10143,10144,10145,10146,10147,10148,10149,10150,10151,10152,10153,10154,10155,10156,10157,10158,10439)")
            ->order("ps desc, g_ntxx_group.full_date")
            ->select();

        $this->assign("data",$data);
        $this->display();
    }

    public function group(){
        $data = M("group")->join('g_ntxx_testee ON g_ntxx_group.id = g_ntxx_testee.group', 'LEFT')
            ->field("name,pc,iF((count(g_ntxx_testee.group)/`pc`*100)>100, 100.00,                  
                          cast(count(g_ntxx_testee.group)/`pc`*100 as decimal(5,2)) ) as ps ")->group("g_ntxx_group.id")
            ->where("g_ntxx_group.id in (10142,10143,10144,10145,10146,10147,10148,10149,10150,10151,10152,10153,10154,10155,10156,10157,10158,10439)")
            ->order("ps desc, g_ntxx_group.full_date")
            ->select();
//        dump($data);
        $this->assign("data",$data);
        $this->display();
    }

}